📚 SAP Business One SDK Help

Adding User Fields - Sample 1
See Also
Private Sub AddUserField()

'//****************************************************************************
'// The UserFieldsMD represents a meta-data object that allows you
'// to add\remove fields from tables or change the fields' characteristics
'//****************************************************************************

    Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD

'//****************************************************************************
'// In any meta-data operation there should be no other object "alive"
'// but the meta-data object, otherwise the operation will fail.
'// This restriction is intended to prevent a collisions.
'//****************************************************************************

    '// The meta-data object needs to be initialized with a
    '// regular UserFields object
    Set oUserFieldsMD = oCompany.GetBusinessObject(oUserFields)

    '//**************************************************
    '// When adding user tables or fields to the SAP Business One database
    '// use a prefix identifying your partner name space
    '// this will prevent collisions between the various partners add-ons
    '//
    '// SAP's name space prefix is "BE_"
    '//**************************************************

    '// Set the Fields' mandatory properties

    oUserFieldsMD.TableName = "OCRD" '// BP table
    oUserFieldsMD.Name = "BE_UserField1"
    oUserFieldsMD.Description = "A user field"
    oUserFieldsMD.Type = db_Alpha '// am alphanumeric type
    oUserFieldsMD.EditSize = 20

    '// Add the field to the table
    oUserFieldsMD.Add

End Sub